\ Preprocessor FOOS demo - Copyright 2012 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

\ Translation of:
\ http://en.wikipedia.org/wiki/Encapsulation_%28object-oriented_programming%29

\        public class Account
\        {
\            private decimal accountBalance = 500.00m;
 
\            public decimal CheckBalance()
\            {
\                return accountBalance;
\            }
\        }
 
\        static void Main()
\        {
\            var myAccount = new Account();
\            var myBalance = myAccount.CheckBalance();
\        }


[pragma] forcecellheap
include lib/ansmem.4th
include lib/fp1.4th
include 4pp/lib/foos.4pp

:: Account
   class
     ffield: accountBalance
     static: CheckBalance
   end-class {

     500 s>f this -> accountBalance f!
     :static CheckBalance { this -> accountBalance f@ } ;
   }

   private{ accountBalance }
;

fvariable myBalance

new Account myAccount
myAccount -> CheckBalance myBalance f!

myBalance f@ f. cr

